package com.bw.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * redisson配置类
 */
@Configuration
public class RedissonConfig {
    @Bean(destroyMethod="shutdown")
    RedissonClient redisson() throws IOException {
        //1、创建配置
        Config config = new Config();
        config//.useReplicatedServers()//主从
                //.useSentinelServers()//哨兵模式
                //.useClusterServers()//集群
                .useSingleServer()//单机
                .setAddress("redis://localhost:6379");
        return Redisson.create(config);
    }
}
